
import { defineConfig } from '@vben/vite-config';

export default defineConfig(async () => {
  return {
    application: {},
    vite: {
      server: {
        proxy: {
          '/admin-api': {
            changeOrigin: true,
            rewrite: (path) => path.replace(/^/admin-api/, ''),
            target: 'http://localhost:48080/admin-api',
            ws: true,
          },
        },
      },
      build: {
        rollupOptions: {
          external: (id) => {
            // 完全忽略所有 jiti 相关模块
            return id.includes('jiti') || 
                   id.includes('@nuxt/kit') || 
                   id.includes('c12') || 
                   id.includes('untyped') ||
                   id.includes('pinia-plugin-persistedstate');
          },
        },
        commonjsOptions: {
          ignore: ['jiti', 'pinia-plugin-persistedstate'],
        },
      },
      define: {
        'process.env.NODE_ENV': '"production"',
        'global': 'globalThis',
      },
    },
  };
});
